//生成 DialogName 类型
var fs = require("fs");

//配置
var filePathDialog = "./assets/resources/Dialog";
var target = "./assets/scripts/GLib/GDialog.ts";
//改变js
var nameType = "type DialogName = ";
let files = fs.readdirSync(filePathDialog, "utf-8");
files = files.filter((file) => {
    return file.endsWith(".prefab");
});
for (let i = 0; i < files.length; i++) {
    let one = files[i];
    if (i == files.length - 1) {
        nameType += `\"${one.slice(0, -7)}\"` + ";";
    } else {
        nameType += `\"${one.slice(0, -7)}\"` + " | ";
    }
    if((i + 1) % 6 == 0){
        nameType += "\n\t";
    }
}
//替换
let dialogContent = fs.readFileSync(target, "utf-8");
dialogContent = dialogContent.replace(/type DialogName = [^;]*;/m, nameType);
fs.writeFileSync(target, dialogContent);



